<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>修改客户风险标记</title>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>
<body class="iframeBody">
<form id="rskCstSignLog_form">
    <div class="fieldset1 tabel_col tabel_col_1 clearFix">
        <div class="fieldBox col_50">
            <div class="label">客户名称</div>
            <div class="field">
                <input name="cstNm" id="cstNm" type="text" class="ui-textbox" value="${rskCstSignLogVO.cstNm}"
                       validate="{required:false,maxlength:60}" readonly="readonly">
                <span class="requiredSymbol">*</span>
            </div>
        </div>
        <div class="fieldBox col_50">
            <div class="label">证件号码</div>
            <div class="field">
                <input name="cstIdcard" id="cstIdcard" type="text" class="ui-textbox" value="${rskCstSignLogVO.cstIdcard}"
                       validate="{required:false,maxlength:60}" readonly="readonly">
                <span class="requiredSymbol">*</span>
            </div>
        </div>
        <div class="fieldBox col_50">
            <div class="label">风险来源</div>
            <div class="field">
                <input name="signSource" id="signSource" placeholder="请选择" ltype="combobox" validate="{required:true}">
                <span class="requiredSymbol">*</span>
            </div>
        </div>
        <div class="fieldBox col_50">
            <div class="label">标记人</div>
            <div class="field">
                <input name="crtUsrNm" id="crtUsrNm" type="text" class="ui-textbox" value="${rskCstSignLogVO.crtUsrNm}"
                       validate="{required:true,maxlength:30}" readonly="readonly">
                <span class="requiredSymbol">*</span>
            </div>
        </div>
        <div class="fieldBox col_50">
            <div class="label">客户类型</div>
            <div class="field">
                <input name="cstTypeCd" id="cstTypeCd" placeholder="请选择" ltype="combobox" validate="{required:true}">
                <span class="requiredSymbol">*</span>
            </div>
        </div>
        <div class="fieldBox col_50">
            <div class="label">标记时间</div>
            <div class="field">
                <input name="crtTm" id="crtTm" type="text" class="ui-textbox" value="${crtTm}"
                       validate="{required:false,maxlength:30}" readonly="readonly">
                <span class="requiredSymbol">*</span>
            </div>
        </div>
        <div class="fieldBox col_50">
            <div class="label">标记类型</div>
            <div class="field">
                <input name="signResType" id="signResType" placeholder="请选择" ltype="combobox" validate="{required:true}">
                <span class="requiredSymbol">*</span>
            </div>
        </div>
        <div class="fieldBox col_50">
            <div class="label">更新标记人</div>
            <div class="field">
                <input name="mdfUsrNm" id="mdfUsrNm" type="text" class="ui-textbox" value="${currentUserName}"
                       validate="{required:true,maxlength:30}" readonly="readonly">
                <span class="requiredSymbol">*</span>
            </div>
        </div>
        <div class="fieldBox col_50">
            <div class="label">标记原因<%-- 1.顶名购买 2.团单拆单 3.老赖 4.诈骗 5.法律纠纷 6.他人运营 7.私下转账 8.代收代付--%></div>
            <div class="field">
                <input name="signResCd" id="signResCd" placeholder="请选择" ltype="combobox" validate="{required:false}">
            </div>
        </div>
        <div class="fieldBox col_50">
            <div class="label">更新标记时间</div>
            <div class="field">
                <input name="mdfTm" id="mdfTm" type="text" class="ui-textbox" value="${mdfTm}"
                       validate="{required:false,maxlength:30}" readonly="readonly">
                <span class="requiredSymbol">*</span>
            </div>
        </div>
        <div class="fieldBox col_50">
            <div class="label">状态</div>
            <div class="field">
                <input name="isValid" id="isValid" placeholder="请选择" ltype="combobox" validate="{required:true}">
                <span class="requiredSymbol">*</span>
            </div>
        </div>
        <div class="fieldBox col_100">
            <div class="label">备注</div>
            <div class="field">
                <textarea name="signRem" id="signRem" type="text" class="ui-textbox" cols="120" rows="7"
                          value=""
                          validate="{required:false,maxlength:255}">${rskCstSignLogVO.signRem}</textarea>
            </div>
        </div>
    </div>
    <div class="btnsBox">
        <span id="saveRskCstSignLog_Btn" class="sq-button sq-button-round l-dialog-btn-ok">保存</span>
        <input type="reset" id="resetBtn" class="l-button l-button-reset Hide">
    </div>

</form>
<script>
    $(function () {
        $("#signResCd").ligerComboBox({
            valueField: 'key',
            textField: 'value'
        });
        $("#signResType").ligerComboBox({
            valueField: 'key',
            textField: 'value'
        });
        $("#signSource").ligerComboBox({
            valueField: 'key',
            textField: 'value'
        });
        $("#cstTypeCd").ligerComboBox({
            valueField: 'key',
            textField: 'value'
        });
        $("#isValid").ligerComboBox({
            valueField: 'key',
            textField: 'value'
        });
        liger.get("signResCd").setData(${signResCdListJson});
        liger.get("signResType").setData(${signResTypeListJson});
        liger.get("signSource").setData(${signSourceListJson});
        liger.get("cstTypeCd").setData(${riskTypeCdListJson});
        liger.get("isValid").setData(${isValidListJson});

        // 当前风险标记原因
        var signResCd = "${rskCstSignLogVO.signResCd}";
        var signResCdNm = "${rskCstSignLogVO.signResCdNm}";
        var signResType = "${rskCstSignLogVO.signResType}";
        var signResTypeNm = "${rskCstSignLogVO.signResTypeNm}";
        var signSource = "${rskCstSignLogVO.signSource}";
        var signSourceNm = "${rskCstSignLogVO.signSourceNm}";
        var cstTypeCd = "${rskCstSignLogVO.cstTypeCd}";
        var cstTypeCdNm = "${rskCstSignLogVO.cstTypeCdNm}";
        var isValid = "${rskCstSignLogVO.isValid}";
        var isValidNam = "有效";
        if(0 == isValid){
            isValidNam = "无效";
        }
        $("#signResCd").val(signResCdNm);
        $("#signResCd").selected = true;
        $("#signResType").val(signResTypeNm);
        $("#signResType").selected = true;
        $("#signSource").val(signSourceNm);
        $("#signSource").selected = true;
        $("#cstTypeCd").val(cstTypeCdNm);
        $("#cstTypeCd").selected = true;
        $("#isValid").val(isValidNam);
        $("#isValid").selected = true;
        liger.get('signSource').setDisabled();
        liger.get('cstTypeCd').setDisabled();

        var cstId = "${rskCstSignLogVO.cstId}"; // 客户ID

        $("#rskCstSignLog_form").ligerForm({
            validate: true
        });
        /*保存*/
        $("#saveRskCstSignLog_Btn").click(function (event) {
            var form = liger.get("rskCstSignLog_form");
            if (!form.valid()) {
                $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO, SQ_type: "warning"});
                return false; //验证不通过，不执行以下代码
            }
            var signRem = $("#signRem").val();
            var signRenLength = getByteLen(signRem);
            if (signRenLength >= 255) {
                $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_SIGNREM_LENGTH, SQ_type: "warning"});
                return false; //验证不通过，不执行以下代码
            }
            var data = form.getData();
            if (data.cstId == null || data.cstId == '') {
                data["cstId"] = cstId;
            }
            if (data.signResCd == null || data.signResCd == '') {
                data["signResCd"] = signResCd;
            }
            if (data.signResType == null || data.signResType == '') {
                data["signResType"] = signResType;
            }
            if (data.signSource == null || data.signSource == '') {
                data["signSource"] = signSource;
            }
            if (data.cstTypeCd == null || data.cstTypeCd == '') {
                data["cstTypeCd"] = cstTypeCd;
            }
            if (data.isValid == null || data.isValid == '') {
                data["isValid"] = isValid;
            }
            $.ligerDialog.hide();
            var _url = '<%=path%>/risk/rskCstSignLog/modify.do';
            var wait_dialog;
            $.ajax({
                type: 'post',
                dataType: 'json',
                data: data,
                url: _url,
                beforeSend: function () {
                    wait_dialog = $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting"});
                },
                success: function (msg) {
                    wait_dialog.close();
                    if (msg.success == 1) {
                        $.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
                        parent.$("#clearBtn").click();
                        parent.$("#searchBtn").click();
                        frameElement.dialog.close();
                    } else {
                        $.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                    }
                }
            });
        });
    });
    // 获取字符串的字节长度
    function getByteLen(str) {
        var len = 0;
        for (var i = 0; i < str.length; i++) {
            var a = str.charAt(i);
            if (a.match(/[^\x00-\xff]/ig) != null) {
                len += 2;
            } else {
                len += 1;
            }
        }
        return len;
    }
</script>
</body>
</html>
